<?php

	@include_once("fta.php");
	if (function_exists('fta_registerModules')){
		fta_registerModules(
			array(
			"cmsConfig",
			"site/fta/config",	
			"FTACart/FTACart"
			)
		);
	} else {
		//we could attempt to fangle the include path.. 
	}
	
	class FTAOrderItem  extends CmsOrderItem {
		
		function __construct(){
			parent::__construct();
			
			$this->keys = array_merge_recursive(
				array(				
						EXTRACT_STRING =>array("productId")
				),
				$this->keys
			);
						
			$this->requiredKeys = array_merge(
				array("productId"), 
				$this->requiredKeys
			);
			
			$this->dataModelKeyMapping = array_merge(
				$this->dataModelKeyMapping,
				array(
					"productId" => "shortdescription"
			    )
            );
			
		}
		
//

		function price(){
			return 0;
		}
		
		function shippingPrice(){
			return 0;
		}
		
		function subTotal(){
			return $this->valueForKey('quantity') * ($this->valueForKey('price') + $this->valueForKey('shippingPrice'));
		}
		
		// abstract method to get the products document.
		// this is basically the unique identifier for the
		// product, it could either be a document code,
		// a cms document type object
		// or some sort of other mess
		// depending on where the product details come from
		function getProductDocument(){
			return 0;
		}
			
		/**
		 * the name of the product
		 * @return String
		 */
		function getProductName() {
			return "No Name";
		}
		
		/**
		 * gets a description for the product
		 * @return String
		 */
		function getProductDescription(){
			return "No Description";
		}
		
		/**
		 * returns a description for the product when generating the invoice.
		 * @return  String the invoice description
		 */
		function getProductInvoiceDescription(){
			return $this->valueForKey('productName'). " - " . $this->valueForKey('productDescription');
		}
		
		/**
		 * returns a url for an image to be displayed in the invoice
		 * @return  String the url for the image
		 */
		function getProductInvoiceImageUrl() {
			return "#";			
		}
		
		/**
		 * returns a url for the product thumbnail image
		 * @return String the url for the image
		 */
		function getProductThumbnailImageUrl() {
			return "#";
		}
		
		/**
		 * returns a url for a large product image
		 * @return String the products large image url
		 */
		function getProductLargeImageUrl() {
			return "#";
		}
		
		/**
		 * returns an entry point into the site where you can access the products details
		 * @return String a url for the product in the site
		 */
		function getProductUrl(){
			return "#";
		}
		
		function save(&$authInfo, &$db ){
			$r = parent::save($authInfo,$db);
			return $r;			
		}
		
		
	}
